package com.neusoft.elm;

import java.util.Scanner;
import com.neusoft.elm.po.Business;
import com.neusoft.elm.view.BusinessView;
import com.neusoft.elm.view.FoodView;
import com.neusoft.elm.view.impl.BusinessViewImpl;
import com.neusoft.elm.view.impl.FoodViewImpl;


public class ElmBusinessEntry {
	
	public void work() {
			 Scanner input = new Scanner(System.in);
		
		//登录初始化页面
			 System.out.print("\r\n" + 
				     "          _____                    _____            _____          \r\n" + 
				     "         /\\    \\                  /\\    \\          /\\    \\         \r\n" + 
				     "        /::\\    \\                /::\\____\\        /::\\____\\        \r\n" + 
				     "       /::::\\    \\              /:::/    /       /::::|   |        \r\n" + 
				     "      /::::::\\    \\            /:::/    /       /:::::|   |        \r\n" + 
				     "     /:::/\\:::\\    \\          /:::/    /       /::::::|   |        \r\n" + 
				     "    /:::/__\\:::\\    \\        /:::/    /       /:::/|::|   |        \r\n" + 
				     "   /::::\\   \\:::\\    \\      /:::/    /       /:::/ |::|   |        \r\n" + 
				     "  /::::::\\   \\:::\\    \\    /:::/    /       /:::/  |::|___|______  \r\n" + 
				     " /:::/\\:::\\   \\:::\\ ___\\  /:::/    /       /:::/   |::::::::\\    \\ \r\n" + 
				     "/:::/__\\:::\\   \\:::|    |/:::/____/       /:::/    |:::::::::\\____\\\r\n" + 
				     "\\:::\\   \\:::\\  /:::|____|\\:::\\    \\       \\::/    / ~~~~~/:::/    /\r\n" + 
				     " \\:::\\   \\:::\\/:::/    /  \\:::\\    \\       \\/____/      /:::/    / \r\n" + 
				     "  \\:::\\   \\::::::/    /    \\:::\\    \\                  /:::/    /  \r\n" + 
				     "   \\:::\\   \\::::/    /      \\:::\\    \\                /:::/    /   \r\n" + 
				     "    \\:::\\  /:::/    /        \\:::\\    \\              /:::/    /    \r\n" + 
				     "     \\:::\\/:::/    /          \\:::\\    \\            /:::/    /     \r\n" + 
				     "      \\::::::/    /            \\:::\\    \\          /:::/    /      \r\n" + 
				     "       \\::::/    /              \\:::\\____\\        /:::/    /       \r\n" + 
				     "        \\::/____/                \\::/    /        \\::/    /        \r\n" + 
				     "         ~~                       \\/____/          \\/____/         \r\n" + 
				     "                                                                   \r\n" + 
				     "");
		
		BusinessView businessView = new BusinessViewImpl();
		Business business = businessView.login();
			 
		//商家登录
		if(business != null) {
			int menu = 0;
			while(menu!=5) {
				//输出一级菜单
				System.out.println("\n======= 一级菜单（商家管理）1.查看商家信息=2.修改商家信息=3.更新密码=4.所属商品管理=5.退出系统=======");
				System.out.println("请输入你的选择：");
				 menu = input.nextInt();
				 
				 switch(menu) {
				 case 1:
				 // System.out.println("查看商家信息");
				 businessView.getBusiness(business.getBusinessID());
				 break;
				 case 2:
				 // System.out.println("修改商家信息");
				 businessView.putBusiness(business.getBusinessID());
				 break;
				 case 3:
				 // System.out.println("更新密码");
				 businessView.patchBusiness_Password(business.getBusinessID());
				 break;
				 case 4:
				 //	 System.out.println("所属商品管理");
				foodManager(business.getBusinessID());
				 
				 break;
				 case 5:
				 System.out.println("------------------------欢迎下次光临饿了么后台管理系统-----------------------");
				 break; 
				 default:
				 System.out.println("没有这个选项！\n");
				 break;
				 }
				 }
			
			
		}else {
			System.out.println("商家编号或密码输入错误！");
		}
		
	}
	
	private void foodManager(int BusinessId) {
		
		Scanner input = new Scanner(System.in);
		 
		 FoodView foodView = new FoodViewImpl();
		 
		 int menu = 0;
		 while(menu!=5) {
		 //输出二级菜单
		 System.out.println("\n======= 二级菜单（食品管理）1.查看食品列表=2.新增食品=3.修改食品=4.删除食品=5.返回一级菜单 =======");
		 System.out.println("请输入你的选择：");
		 menu = input.nextInt();
		 
				 switch(menu) {
				 case 1:
				 foodView.getFoodlist(BusinessId);
				 break;
				 case 2:
				 foodView.postFood(BusinessId);
				 break;
				 case 3:
				 foodView.putFood(BusinessId);
				 break;
				 case 4:
				 foodView.deleteFood(BusinessId);
				 break;
				 case 5:
				 break; 
				 default:
				 System.out.println("没有这个选项！\n");
				 break;
				 }
			}
		}
	
	 public static void main(String[] args) {
		 new ElmBusinessEntry().work();
		 }
}
